from flask import Flask, render_template
from flask import request, jsonify
from flask_script import Manager
from flask.ext.pymongo import PyMongo
from flask_restful import Api 

app = Flask(__name__)
mongo = PyMongo(app)
manager = Manager(app)
api = Api(app)

@app.route('online')
def home():
    online_users = mongo.db.users.find({'online': True})
    return jsonify(online_users)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/user/<name>')
def user(name):
    return render_template('user.html', name=name)

class HelloWorld(restful.Resource):
    def get(self):
        return {'hello':'world'}

api.add_resource(HelloWorld, '/')

if __name__ == '__main__':
    manager.run()
